@use "./variables" as *;
@use "sass:math";

*,
*::before,
*::after {
  transition: $transitionBgColor, $transitionBorderColor;
}

a,
span {
  transition: $transitionColor;
}

a.header-anchor {
  font-size: 0.85em;
  float: left;
  margin-left: -0.87em;
  padding-right: 0.23em;
  margin-top: 0.125em;
  opacity: 0;
  &:focus,
  &:hover {
    text-decoration: none;
  }
}

.flex {
  display: flex;
  &.justify-center {
    justify-content: center;
  }
  &.align-center {
    align-items: center;
  }
}

.flex-row {
  @extend .flex;
  flex-direction: row;
}

.flex-column {
  @extend .flex;
  flex-direction: column;
}

.flex-1 {
  flex: 1;
}

.inline-block {
  display: inline-block;
}

.box-shadow {
  box-shadow: 0 0 10px 1px var(--shadowColor);
}

.card {
  @extend .box-shadow;
  border-radius: 5px;
  background: var(--mainBg);
  transition: $transitionBoxShadow, $transitionBgColor;
  &:hover {
    box-shadow: 0 0 10px 3px var(--accentShadowColor);
  }
}

.is-link {
  &,
  & a,
  & span {
    cursor: pointer;
    color: var(--textColor);
  }
  &:hover,
  &:hover a,
  &:hover span {
    color: var(--accentColor);
  }
}

.accent-underline {
  position: relative;
  padding-bottom: 0.2em;
  &::after {
    content: "";
    transition: all 0.2s ease-out;
    display: block;
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    border-bottom: 0.2em solid var(--accentColor);
  }
  &.router-link-exact-active::after {
    left: 0;
    width: 100%;
  }
  &:has(.router-link-exact-active) {
    &::after {
      left: 0;
      width: 100%;
    }
  }
  &:hover,
  &:focus,
  &:active {
    &::after {
      left: 0;
      width: 100%;
    }
  }
}

.navbar {
  @extend .box-shadow;
  box-sizing: border-box;
  height: $navbarHeight;
  position: fixed;
  width: 100%;
  background-color: var(--mainBg);
  z-index: 100;
  padding: 0.8rem 1.5rem;
  display: flex;
  flex-direction: row;
  .logo {
    display: flex;
    align-items: center;
    img {
      height: 2rem;
      width: 2rem;
      margin-right: 0.5rem;
    }
    a,
    span {
      font-weight: bold;
      font-size: 1.2rem;
      color: var(--textColor);
    }
  }
  .nav-links {
    flex: 1;
    display: flex;
    flex-direction: row;
    height: 100%;
    align-items: center;
    justify-content: right;
    .nav-item {
      margin-left: 1.5rem;
      span,
      a {
        &.router-link-exact-active {
          color: var(--accentColor);
        }
      }
    }
  }
}

.main-wrapper {
  margin: auto;
  box-sizing: border-box;
  padding: 1.5rem;
  padding-top: $navbarHeight + 2rem;
}

.page-wrapper {
  @extend .main-wrapper;
  min-height: calc(100vh - $footerHeight);
  .sidebar-open & {
    padding-left: $sidebarWidth;
  }
  .plain-wrapper {
    box-sizing: border-box;
    margin: auto;
    padding: 0;
    max-width: $contentWidth;
  }
  .article-wrapper {
    @extend .box-shadow, .plain-wrapper;
    padding: 1rem 2.5rem 2rem;
    border-radius: 1rem;
    background-color: var(--mainBg);
    & > :not(.article-info) {
      user-select: text;
    }
    img {
      max-width: 100%;
    }
    p,
    h1,
    h2,
    h3,
    h4,
    h5,
    h6,
    & > ul > li,
    & > ol > li {
      transition: $transitionColor, $transitionBorderColor;
    }
  }
  .readme-wrapper {
    @extend .article-wrapper;
  }
  .home-wrapper {
    @extend .plain-wrapper;
    max-width: $contentWidthWide;
  }
  .categories-wrapper {
    @extend .plain-wrapper;
    max-width: $contentWidthWide;
  }
  .tags-wrapper {
    @extend .plain-wrapper;
    max-width: $contentWidthWide;
  }
  .archives-wrapper {
    @extend .plain-wrapper;
    max-width: $contentWidthWide;
  }
  .friends-wrapper {
    @extend .plain-wrapper;
  }
}

.footer {
  display: flex;
  flex-direction: column;
  height: $footerHeight;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  color: var(--footerColor);
  font-size: 0.8em;
}

.disabled {
  cursor: not-allowed !important;
  color: var(--disabledColor) !important;
}

.custom-container {
  margin: 1rem 0;
  .details {
    background-color: var(--codeBg);
    padding: 1em 1.5em;
    border-radius: 6px;
    summary {
      cursor: pointer;
    }
  }
  .info {
    --c-border: #888;
    --c-icon: var(--c-border);
    --c-title: var(--textColor);
    --c-text: var(--textColor);
    --c-bg: var(--codeBg);
    border-left: 0.5em var(--c-border) solid;
    padding: 1px 1.5em;
    background-color: var(--c-bg);
    color: var(--c-text);
    .title {
      color: var(--c-title);
      &::before {
        display: inline-block;
        transform: scale(1.5);
        margin-right: 1em;
        color: var(--c-icon);
      }
    }
  }
  .tip {
    @extend .info;
    --c-border: #42b96a;
  }
  .warning {
    @extend .info;
    --c-border: #e7c000;
    --c-title: #ad9000;
    --c-text: #746000;
    --c-bg: #fffae3;
  }
  .danger {
    @extend .info;
    --c-border: #cc0000;
    --c-title: #990000;
    --c-text: #660000;
    --c-bg: #ffe0e0;
  }
}
